<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<title>${SYSTEM_NAME}</title>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
  	<!-- 文件上传 -->
  	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/fileUpload.css?v=${FILE_VERSION}">
	<style>
		.dirIl{
			cursor: pointer;background-color:#fff;font-size: 18px;padding: 5px
		}

		.dirIl:hover{
			background-color:#dbe9ff;color: #09AAFF;
		}

		.ilSelected{
			background-color:#dbe9ff;color: #09AAFF;border-left: 4px solid #09AAFF;font-weight: bold;
		}
	</style>
</head>
<body>
	<div class="layui-fluid" style="background-color: #fff;">
		<form class="layui-form" method="post" id="basicform" >
			<input type="hidden" name="ids" value="${ids}">
			<div style="text-align: center;
			border: 1px solid #ccc;
			margin: 0 auto;height: 380px;overflow: auto;" >
				<input type="hidden" id="dirId" name="dirId">
				<ul id="dirUl">
					<li class="dirIl" value="0" onclick="liClick(this)">默认目录</li>
					<c:forEach items="${fileDirList}" var="t">
						<li class="dirIl" dataId="${t.id}" onclick="liClick(this)">${t.name}</li>
					</c:forEach>
				</ul>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-primary layui-border-blue" lay-submit="" lay-filter="sub">移动</button>
					<button type="button" class="layui-btn layui-btn-primary layui-border-red" onclick="closed()">关闭</button>
				</div>
			</div>

		</form>
	</div>
	<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
	<script>
		layui.use(['form'], function() {
			var form = layui.form;

			form.on('submit(sub)', function(data){
				if(isNull($("#dirId").val())){
					layer.msg("请选择要移动的目录");
					return;
				}
				$ajax({
					url: "/sys/file/moveFiles",
					data :  data.field,
			        succCallback: function (json) {
			        	if(json.code == 0){
			        		parent.moveFileBack($("#id").val());
		            		parent.layer.closeAll();
		            		parent.layer.msg(json.msg);
			        	}
			        }
				});
				return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
			});
		});

		function liClick(li) {
			var lis = $(li).siblings();
			$(lis).each(function(){
				$(this).removeClass("ilSelected");
			});
			$(li).addClass("ilSelected");
			$("#dirId").val($(li).attr("dataId"));
		}
		
		function closed(){
			var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
			parent.layer.close(index);//关闭弹出的子页面窗口
		}
	</script>
</body>
</html>